package com.leyou.item.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.leyou.item.entiey.Sku;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.Map;

public interface SkuMapper extends BaseMapper<Sku> {

    @Update("update tb_sku set saleable = #{saleable} where spu_id = #{id}")
    Boolean goodsIsSaleable(@Param("id") Long id,@Param("saleable") Boolean saleable);

    @Update("UPDATE tb_sku SET stock = stock - #{num}, sold = sold + #{num} WHERE id = #{id} and saleable = 1")
    int deductStock(Map<String,Object> sku);

/*    @Update("update tb_sku set stork = #{stork} where spu_id = #{id}")
    void updateStork(@Param("id") Long id,@Param("stork") Integer stock);*/
}